# -*- coding:utf-8 -*-


from sqlalchemy.ext.asyncio import AsyncSession
from {{ module_name }}.dao.{{ table_name }}_dao import {{ table_name|snake_to_pascal_case }}Dao
from {{ module_name }}.entity.do.{{ table_name }}_do import {{ table_name|snake_to_pascal_case }}
from {{ module_name }}.entity.vo.{{ table_name }}_vo import {{ table_name|snake_to_pascal_case }}PageModel, {{ table_name|snake_to_pascal_case }}Model


class {{ table_name|snake_to_pascal_case }}Service:
    """
    用户管理模块服务层
    """

    @classmethod
    async def get_{{ table_name }}_list(cls, query_db: AsyncSession, query_object: {{ table_name|snake_to_pascal_case }}PageModel, data_scope_sql: str) -> list[{{ table_name|snake_to_pascal_case }}]:
        {{ table_name }}_list = await {{ table_name|snake_to_pascal_case }}Dao.get_{{ table_name }}_list(query_db, query_object, data_scope_sql, is_page=True)
        return {{ table_name }}_list


    @classmethod
    async def add_{{ table_name }}(cls, query_db: AsyncSession, query_object: {{ table_name|snake_to_pascal_case }}Model) -> {{ table_name|snake_to_pascal_case }}:
        {{ table_name }} = await {{ table_name|snake_to_pascal_case }}Dao.add_{{ table_name }}(query_db, query_object)
        return {{ table_name }}


    @classmethod
    async def update_{{ table_name }}(cls, query_db: AsyncSession, query_object: {{ table_name|snake_to_pascal_case }}Model) -> {{ table_name|snake_to_pascal_case }}:
        {{ table_name }} = await {{ table_name|snake_to_pascal_case }}Dao.edit_{{ table_name }}(query_db, query_object)
        return {{ table_name }}


    @classmethod
    async def del_{{ table_name }}(cls, query_db: AsyncSession, query_object: {{ table_name|snake_to_pascal_case }}Model):
        await {{ table_name|snake_to_pascal_case }}Dao.del_{{ table_name }}(query_db, query_object)
